#ifndef __BSP_FLASH_H
#define __BSP_FLASH_H
#include "main.h"

#define FLASH_CS_CLR            PBout(12)=0
#define FLASH_CS_SET            PBout(12)=1

#define FLASH_HANDLE            &hspi2

#define FLASH_PAGE_SIZE         256
#define FLASH_SECTOR_SIZE       4096
#define FLASH_SECTOR_COUNT      4096

#define MAX_TIME_OUT            200

#define FONT_GBK_INDEX_START    0x000000    
#define FONT_GBK_INDEX_END      0x006CCC    //utf16->gb2312 映射表 共27852字节

#define FONT_GBK_SHADE_START1   0x007000 //65536
#define FONT_GBK_SHADE_START2   0x017000 //65536
#define FONT_GBK_SHADE_START3   0x027000 //65536
#define FONT_GBK_SHADE_START4   0x037000 //47040
#define FONT_GBK_SHADE_END      0x0427C0    //gb2312字形共243648字节


void bsp_flash_init(void);
void bsp_flash_erasesector(uint32_t u32Addr);
void bsp_flash_read(uint32_t u32Addr, uint8_t *pu8Buffer, uint16_t u16ByteCount);
void bsp_flash_write_page(uint32_t u32Addr, uint8_t *pu8Buffer, uint16_t u16ByteCount);
void bsp_flash_write_sector(uint32_t u32Addr, const uint8_t *pu8Buffer, uint32_t u32ByteCount);

uint32_t _flash_addr_byblocksector(uint8_t u8Block, uint8_t u16Sector);
uint32_t _flash_addr_byblock(uint8_t u8Block);
uint32_t _flash_addr_bysector(uint16_t u16Sector);
uint32_t _flash_addr_byblocksectorpage(uint8_t u8Block, uint8_t u16Sector, uint8_t u1);

#endif /* __BSP_FLASH_H */
